//
//  Emoticon.swift
//  01-表情键盘(绑定数据)
//
//  Created by gxiangzi on 15/9/14.
//  Copyright © 2015年 hqu. All rights reserved.
//

import UIKit

class Emoticon: NSObject {
   
    // 表情文字
    var chs : String?
    // 图片设置
    var png : String?
    
    // 设置图片路径
    var filePath :String? {
        return (png != nil) ? NSBundle.mainBundle().bundlePath + "/Emoticons.bundle/" + png! : ""
    }
    
    /// emiji 字符串
    var emoji: String?
    
    // emoji编码
    var code :String? {
        didSet {
        // 1.读取 16 进制
        let scanner = NSScanner(string: code!)
            
        var value :UInt32 = 0
            
        scanner.scanHexInt(&value)
            
        emoji = String(Character(UnicodeScalar(value)))
        
        }
    }
    
    
    // 定义是否是删除
    var  isRemove:Bool = false
    
    init(isRemove:Bool) {
        self.isRemove = isRemove
        super.init()
    }
    
    // 定义是否空白
    var isBlack:Bool = false
    init(isBlack :Bool) {
        self.isBlack = isBlack
        super.init()
    }

    
    init(dict:[String : String])
    {
        super.init()
        setValuesForKeysWithDictionary(dict)
    }
    
    override func setValue(value: AnyObject?, forUndefinedKey key: String) {}
    
    override var description: String {
        let keys = ["chs", "png", "code"]
        
        return dictionaryWithValuesForKeys(keys).description
    }
    
}
